package org.skydiveapphd;

import org.skydiveapplibrary.R;

import android.app.ExpandableListActivity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.TextView;

public class BaseExpandableListActivity extends ExpandableListActivity
{
	
	private OnClickListener topClickListener = new OnClickListener()
	{
		@Override
		public void onClick(View view)
		{
			onTopButtonClick();
		}
	};
	private OnClickListener bottomClickListener = new OnClickListener()
	{
		@Override
		public void onClick(View view)
		{
			onBottomButtonClick();
		}
	};
	
    @Override 
    public void onCreate(Bundle savedInstanceState)
    { 
    	super.onCreate(savedInstanceState);
    	
    	// show view
		setContentView(R.layout.expandable_list_view);
		
		// add listeners
		ImageButton leftButton = (ImageButton) findViewById(R.id.ExpandableListTopButton);
		leftButton.setOnClickListener(topClickListener);
		
		ImageButton rightButton = (ImageButton) findViewById(R.id.ExpandableListBottomButton);
		rightButton.setOnClickListener(bottomClickListener);
    }
  
    protected void onTopButtonClick()
    {
    	// do nothing
    }
    
    protected void onBottomButtonClick()
    {
    	// do nothing
    }
    
    protected void setHeaderText(int id)
    {
		// set header label
		TextView textView = (TextView)findViewById(R.id.ListHeaderTextView);
		textView.setText(id);
    }
    
    protected void setTopButtonImage(int id)
    {
    	ImageButton button = (ImageButton) findViewById(R.id.ExpandableListTopButton);
    	button.setImageResource(id);
    }
    
    protected void setTopButtonVisibility(int visibility)
    {
    	ImageButton button = (ImageButton) findViewById(R.id.ExpandableListTopButton);
    	button.setVisibility(visibility);
    }
    
    protected void setBottomButtonImage(int id)
    {
    	ImageButton button = (ImageButton) findViewById(R.id.ExpandableListBottomButton);
    	button.setImageResource(id);
    }
    
    protected void setBottomButtonVisibility(int visibility)
    {
    	ImageButton button = (ImageButton) findViewById(R.id.ExpandableListBottomButton);
    	button.setVisibility(visibility);
    }
}
